-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(messages): reuse the first valid message ID for subsequent chunks #798
base: main
Are you sure you want to change the base?
Conversation
@@ -8564,24 +8564,6 @@ graph TD; | |||
tags: ["c_two_chat_model"], | |||
}, | |||
], | |||
[ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
were these being emitted by mistake?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think so? @jacoblee93 can clarify, but it doesn't make sense to emit the message twice
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cool yea def don't want to emit things twice, can you point me to the line that was causing this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The issue happens on when we emit the actual chunk instead of a raw message: https://github.com/langchain-ai/langgraphjs/pull/798/files?w=1#diff-fdc54140c541e7ddfea663ff6751691ca2971772df39a299c904947b27873560R127
c5f0d2f
to
81a1345
Compare
// we rename the message ID if it's being auto-set to `run-${runId}` | ||
// (see https://github.com/langchain-ai/langchainjs/pull/6646). | ||
let messageId = message.id; | ||
if (messageId == null || messageId === `run-${runId}`) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would this suffice instead of ==
? It seems like the original condition was checking for undefined as well, so this might be better to catch both cases.
if (messageId == null || messageId === `run-${runId}`) { | |
if (!messageId || messageId === `run-${runId}`) { |
Fixes # (issue)